<!-------- @HEADER
 !
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
 !  Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring
 !                  Copyright 2012 Sandia Corporation
 !
 ! Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
 ! the U.S. Government retains certain rights in this software.
 !
 ! Redistribution and use in source and binary forms, with or without
 ! modification, are permitted provided that the following conditions are
 ! met:
 !
 ! 1. Redistributions of source code must retain the above copyright
 ! notice, this list of conditions and the following disclaimer.
 !
 ! 2. Redistributions in binary form must reproduce the above copyright
 ! notice, this list of conditions and the following disclaimer in the
 ! documentation and/or other materials provided with the distribution.
 !
 ! 3. Neither the name of the Corporation nor the names of the
 ! contributors may be used to endorse or promote products derived from
 ! this software without specific prior written permission.
 !
 ! THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
 ! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 ! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 ! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
 ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 ! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 ! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 ! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 !
 ! Questions? Contact Karen Devine	kddevin@sandia.gov
 !                    Erik Boman	egboman@sandia.gov
 !
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !
 ! @HEADER
-------> 
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; U; SunOS 5.6 sun4m) [Netscape]">
   <meta name="sandia.approved" content="SAND99-1376">
   <meta name="author" content="karen devine, kddevin@sandia.gov">
   <title> Zoltan Developer's Guide:  Adding Algorithms</title>

</head>
<body bgcolor="#FFFFFF">

<div align=right><b><i><a href="dev.html">Zoltan Developer's Guide</a>&nbsp;
|&nbsp; <a href="dev_add_interface.html">Next</a>&nbsp; |&nbsp; <a href="dev_services_debug.html">Previous</a></i></b></div>

<h2>
<a NAME="new_methods"></a>Adding New Load-Balancing Algorithms to Zoltan</h2>
The Zoltan library is designed so that adding new load-balancing algorithms
to the library is simple. In many cases, existing code can be easily modified
to use the interface query functions to build the data structures needed
for the algorithm. The process for adding new algorithms to the library
is described below; more detail is provided at each link.
<ol>
<li>
Make sure you follow the <a href="dev_intro_philosophy.html">Philosophy
of Zoltan</a> and the <a href="dev_intro_coding.html">Coding Principles
in Zoltan</a>.</li>

<li>
Use the <a href="dev_add_struct.html">Data Structures</a>
provided by Zoltan.</li>

<li>
Implement a <a href="dev_add_lb.html">Load-Balancing Function</a> front-end
to the algorithm. Note that Zoltan load-balance methods should assign objects both to processors and parts, which may be different. The recommended strategy is to assign objects to parts first, then use Zoltan_LB_Part_To_Proc to generate the corresponding processors.</li>

<li>
Add the algorithm to the <a href="dev_add_interface.html">Load-Balancing
Interface Routines</a>.</li>

<li>
Add the <a href="dev_add_params.html">Parameters</a> needed by the algorithm.
Also make sure that the algorithm uses the <a href="../ug_html/ug_param.html#General_Parameters">General Parameters</a> in Zoltan properly, in particular 
<a href="../ug_html/ug_alg.html#LB Parameters"><b>Imbalance_Tol</b></a> and
<a href="../ug_html/ug_param.html#Debug Levels in Zoltan"><b>Debug_Level.</b></a></li>

<li>
If necessary, write a routine to free your dynamically allocated data structures.
See tips on <a href="dev_add_memory.html">memory management</a></li>
in Zoltan.</a></li>

<li>
If your algorithm uses persistent data structures,
like the RCB tree with <a href="../ug_html/ug_alg_rcb.html">KEEP_CUTS</a>,
write a routine to copy your load balancing 
<a href="dev_add_struct.html#Copy">data structure</a>. </li>

<li>
We recommend you add part remapping to your algorithm using
<a href="dev_add_.html"><b>Zoltan_LB_Remap</b></a>.</li>

<li>
Update the <a href="dev_fortran.html#fortran dev add">Fortran</a>
and <a href="dev_cpp.html">C++</a> interfaces, if necessary.</li>

<li>
Document your new method. The documentation should be written in a format
that can easily be converted into HTML and PDF.  Consider adding a
simple application to the <I>examples</I> directory demonstrating the
use of your method.</li>

<li>
Please contact the Zoltan team if you would like your method to be distributed
with future versions of Zoltan.</li>

</ol>

<hr WIDTH="100%">
<br>[<a href="dev.html">Table of Contents</a>&nbsp; |&nbsp; <a href="dev_add_interface.html">Next:&nbsp;
Load-Balancing Interface Routines</a>&nbsp; |&nbsp; <a href="dev_services_debug.html">Previous:&nbsp;
Debugging Services</a>&nbsp; |&nbsp; <a href="https://www.sandia.gov/general/privacy-security/index.html">Privacy and Security</a>]
</body>
</html>
